<?php

function wptravel_install()
{
	global $wpdb;

	$table_name = $wpdb->prefix . 'wptravel';
	
	if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
	
		$sql = 'CREATE TABLE ' . $table_name . " (
		  `wptravelId` bigint(20) unsigned NOT NULL auto_increment,
		  `post_ID` bigint(20) unsigned NOT NULL,
		  `startDate` date NOT NULL,
		  `endDate` date NOT NULL,
		  `price` decimal(10,2) unsigned default NULL,
		  `currency` enum('CDN','USD','EUR') NOT NULL default 'CDN',
		  `closed` enum('y','n') NOT NULL default 'n',
		  `guaranteed` enum('y','n') NOT NULL default 'n',
		  `limited` enum('y','n') NOT NULL default 'n',
		  `airIncluded` enum('y','n') NOT NULL default 'n',
		  `accommodation` enum('single','double','triple','quad','group') NOT NULL default 'single',
		  PRIMARY KEY  (`wptravelId`),
		  KEY `post_ID` (`post_ID`)
		);'";
		
		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
		dbDelta($sql);
		
	}
	
}